namespace Sirius.Mapper
{
    using System;
    using Exceptions;
    using Internals;

    public static class Mapper
    {
        public static ITypeMapping<T> CreateMapping<T>()
        {
            return new TypeMapping<T>();
        }

        public static ISession CreateSession(IProvider provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            var session = new Session(provider);
            session.Open();

            return session;
        }

        public static ISingleSet<T> AsSingleSet<T>(this IDataSource source)
            where T : new()
        {
            return new SingleSet<T>(source);
        }

        public static IMultipleSet AsMultipleSet(this IDataSource source)
        {
            return new MultipleSet(source);
        }

        public static IScalarSet<T> AsScalarSet<T> (this IDataSource source)
        {
            return new ScalarSet<T>(source);
        }

        public static IManager<T, TKey> Manager<T, TKey>(ISession session, ITypeMapping<T> mapping)
        {
            return new Manager<T, TKey>(session, mapping);
        }
    }
}